﻿using System.Collections;
using System.Collections.Generic;

namespace _1_4
{
    class Product
    {
        readonly string name;
        public string Name { get { return name; } }

        readonly decimal price;
        public decimal Price { get { return price; } }

        public Product(string name, decimal price)
        {
            this.name = name;
            this.price = price;
        }

        public static List<Product> GetSampleProducts()
        {
            return new List<Product>
            {
                new Product(name: "West Side Story", price: 9.99m),
                new Product(name: "Assassins", price: 14.99m),
                new Product(name: "Frogs", price: 13.99m),
                new Product(name: "Sweeny", price: 10.99m)
            };
        }

        public override string ToString()
        {
            return string.Format("{0}: {1}", name, price);
        }
    }
}
//readonly变量可以在定义时赋值，也可以在构造方法中赋值或者修改定义时赋给的初始值；
//在调用函数时可以指定参数名称传参数，而不是按照顺序填写参数。